/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.generate;

import com.gitee.peigenlpy.sansheng.core.util.CodeGenerateAction;
import com.gitee.peigenlpy.sansheng.core.util.CodeGenerateUtil;
import com.google.common.collect.Sets;
import info.peigen.hotpot.manage.core.repository.entity.UserEntity;

import java.io.File;
import java.io.IOException;
import java.util.Set;

/**
 * <b>(CodeGenerate)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/7/21
 */
@SuppressWarnings("unused")
public class CodeGenerate {
    private final static String        USER_DIR     = System.getProperty("user.dir") + File.separator + "hotpot-generate";
    // private final static Set<Class<?>> CLASSES      = Sets.newHashSet(OrganizationEntity.class, PositionEntity.class,
    //         RelationEntity.class, ResourceEntity.class, RoleEntity.class);
    private final static Set<Class<?>> CLASSES      = Sets.newHashSet(UserEntity.class);
    private final static String        PACKAGE_PATH = "info.peigen.hotpot.manage.core.repository.entity";

    public static void main(String[] args) throws IOException {
        System.setProperty("user.dir", USER_DIR);
        generateAllByPackagePath();


        // generateAll();
        // generate();
        // generateFe();
        // generateSql();
    }

    public static void generateAllByPackagePath() {
        CodeGenerateAction action = CodeGenerateAction.all();
        CodeGenerateUtil.execute(action, PACKAGE_PATH);
    }

    public static void generateAll() throws IOException {
        CodeGenerateAction action = CodeGenerateAction.all();
        CodeGenerateUtil.execute(action, CLASSES);
    }

    public static void generate() throws IOException {
        CodeGenerateAction action = CodeGenerateAction.builder()
                // .createController(true)
                // .createSearchForm(true)
                // .createCreateForm(true)
                // .createEditForm(true)
                // .manageInfo(true)
                // .manageService(true)
                // .manageFeApi(true)
                // .manageFeIndex(true)
                // .manageFeForm(true)
                .fe(true)
                // .test(true)
                .build();
        CodeGenerateUtil.execute(action, PACKAGE_PATH);
    }

    public static void generateFe() throws IOException {
        CodeGenerateAction action = CodeGenerateAction.builder()
                .fe(true)
                .build();
        CodeGenerateUtil.execute(action, CLASSES);
    }

    public static void generateSql() throws IOException {
        CodeGenerateAction action = CodeGenerateAction.builder()
                .manageMenuSql(true)
                .build();
        CodeGenerateUtil.execute(action, CLASSES);
    }

}